const mockData = require('../../utils/data.js')

Page({
  data: {
    destinationId: null,
    category: null,
    products: [],
    currentTab: 'all',
    tabs: ['全部', '门票&演出', '一日游&小团游', '当地跟团', '特色活动&']
  },
  
  onLoad(options) {
    const destinationId = options.destinationId
    const category = options.category
    const tab = options.tab || 'all'
    
    this.setData({
      destinationId,
      category,
      currentTab: tab
    })
    
    this.loadProducts()
  },
  
  loadProducts() {
    // 模拟加载产品
    this.setData({
      products: mockData.products
    })
  },
  
  switchTab(e) {
    const tab = e.currentTarget.dataset.tab
    this.setData({
      currentTab: tab
    })
    this.loadProducts()
  },
  
  goToProductDetail(e) {
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/product-detail/product-detail?id=${id}`
    })
  }
})


